import sys
import json
from pymongo import MongoClient
from decimal import Decimal
db_name=sys.argv[1]
client=MongoClient("182.92.96.120",3719)
db=client['admin']
db.authenticate('root', 'zhuge1116')
db=client[db_name]
borough_price_file="%s_borough_price" % db_name
def default(obj):
    if isinstance(obj, Decimal):
        return str(obj)
    raise TypeError
newitem={}
with open(borough_price_file, 'w') as f:
    for item in db['borough_list_price'].find():
        newitem['borough_id']= item['borough_id']
	newitem['price'] = item['price']
	f.write(json.dumps(newitem,default=default))
	f.write("\n")

